package crl.levelgen;

import sz.util.*;
import crl.level.*;
import crl.game.*;
import crl.feature.*;

public class TestLevelGenerator extends LevelGenerator {
	public final static String [] descriptions = new String [] {
    	"COURTYARDGRASS",
		"COURTYARDDIRT",
		"BRICKWALKWAY",
		"COURTYARDDOOR",
		"COURTYARDWALL",
		"CASTLEWALL",
		"GARGOYLESTATUE",
		"HUMANSTATUE",
		"DARKTREE",
		"DEADSTUMP",
		"TORCH",
		"FENCE",
		"CASTLEDOOR",
		"FOUNTAINCENTER",
		"FOUNTAINAROUND",
		"FOUNTAINPOOL",
		"STREAM"
	};

	public Level generateLevel(String param, Dispatcher dispa){
		MapCellFactory mcf = MapCellFactory.getMapCellFactory();
		FeatureFactory ff = FeatureFactory.getFactory();
		int [][] imap = new int [][]
	{
		{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 8, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 5, 5, 5, 5},
		{ 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 0, 8, 8, 8, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 8, 8, 8, 0, 4, 0, 5, 5, 5, 5},
		{ 8, 8, 8, 8, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 5, 5, 5, 5},
		{ 8, 8, 8, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0,16,16,16,16, 0, 0, 0, 0, 0, 0, 0, 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, 4, 4, 4, 4, 0, 5, 5, 5, 5},
		{ 8, 0, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 0, 8, 8, 8, 4, 4, 4, 4, 4, 4, 0, 0, 0, 8, 8, 8, 8, 0, 0, 4, 0, 5, 5, 5, 5},
		{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 8, 8, 4, 4, 5, 5, 5, 5},
	};

		Cell [][][] cmap = new Cell[1][imap[0].length][imap.length];

		for (int y=0; y<imap.length; y++){

			for (int x = 0; x <imap[0].length; x++) {
				try {
					cmap[0][x][y] = mcf.getMapCell(descriptions[imap[y][x]]);
				} catch (CRLException crle){
					Debug.byebye("Exception creating the level "+crle);
				}
			}
		}

		Level ret = new Level();
		ret.setCells(cmap);
		//ret.setDispatcher(dispa);
		//ret.setMOF(mof);
		//ret.respawn();
			   /*
		for (int i = 0; i <10; i++){
			Monster bat = mof.buildMonster("SKELETON");

			bat.setPosition(i+5,i+5);
			ret.addMonster(bat);
			//dispa.addActor(bat);
		}



		for (int i = 0; i <10; i++){
			Monster bat = mof.buildMonster("PANTHER");

			bat.setPosition(i+7,10);
			ret.addMonster(bat);
			//dispa.addActor(bat);
		}    */


		Feature c1 = ff.buildFeature("CANDLE");
		c1.setPosition(9,17,0);
		ret.addFeature(c1);

		c1 = ff.buildFeature("CANDLE");
		c1.setPosition(16,17,0);
		ret.addFeature(c1);
		c1 = ff.buildFeature("BIGCANDLE");
		c1.setPosition(23,17,0);
		ret.addFeature(c1);
		c1 = ff.buildFeature("BIGCANDLE");
		c1.setPosition(31,17,0);
		ret.addFeature(c1);
		c1 = ff.buildFeature("CANDLE");
		c1.setPosition(37,17,0);
		ret.addFeature(c1);
		c1 = ff.buildFeature("BIGCANDLE");
		c1.setPosition(53,17,0);
		ret.addFeature(c1);
		c1 = ff.buildFeature("CANDLE");
		c1.setPosition(9,26,0);
		ret.addFeature(c1);

		c1 = ff.buildFeature("CANDLE");
		c1.setPosition(16,26,0);
		ret.addFeature(c1);
		c1 = ff.buildFeature("BIGCANDLE");
		c1.setPosition(23,26,0);
		ret.addFeature(c1);
		c1 = ff.buildFeature("BIGCANDLE");
		c1.setPosition(31,26,0);
		ret.addFeature(c1);
		c1 = ff.buildFeature("CANDLE");
		c1.setPosition(37,26,0);
		ret.addFeature(c1);
		c1 = ff.buildFeature("BIGCANDLE");
		c1.setPosition(53,26,0);
		ret.addFeature(c1);

		c1 = ff.buildFeature("ENDFLOOR");
		c1.setPosition(55,20,0);
		ret.addFeature(c1);

		/*for (int i=0; i<5; i++){
			String monst = "";
			switch (Util.rand(0,4)){
				case 0:
					monst = "BAT";
					break;
				case 1:
					monst = "SKELETON";
					break;
				case 2:
					monst = "ZOMBIE";
					break;
				case 3:
					monst = "PANTHER";
					break;
				case 4:
					monst = "MERMAN";
					break;
			}
			Monster bat = mof.buildMonster(monst);
			bat.setPosition(Util.rand(5,60), Util.rand(5,30));
			ret.addMonster(bat);
		}

		for (int i = 0; i <5; i++){
			Monster bat = mof.buildMonster("MERMAN");

			bat.setPosition(7,35);
			ret.addMonster(bat);
		}

		  */

		c1 = ff.buildFeature("DAGGERCANDLE");
		c1.setPosition(5,5,0);
		ret.addFeature(c1);

		c1 = ff.buildFeature("AXECANDLE");
		c1.setPosition(9,18,0);
		ret.addFeature(c1);

		c1 = ff.buildFeature("HOLYCANDLE");
		c1.setPosition(5,30,0);
		ret.addFeature(c1);

		c1 = ff.buildFeature("STOPWATCHCANDLE");
		c1.setPosition(60,30,0);
		ret.addFeature(c1);

		c1 = ff.buildFeature("STOPWATCHCANDLE");
		c1.setPosition(60,30,0);
		ret.addFeature(c1);

		c1 = ff.buildFeature("CROSSCANDLE");
		c1.setPosition(30,10,0);
		ret.addFeature(c1);
		return ret;
	}


}